﻿net_expand_east_indies = {
	is_shown = {
		country_is_in_europe = yes
		exists = c:BEI
		c:BEI = {
			is_subject_of = ROOT
			is_subject_type = subject_type_dominion
		}
	}
	possible = {
		OR = { 
			any_state = {
				owner = ROOT
				region = sr:region_indonesia
			}
			any_subject_or_below = {
				capital.region = sr:region_indonesia
				NOT = { 
					THIS = c:BEI
					is_subject_of = c:BEI
				}
			}
		}
	}
	when_taken = {
		custom_tooltip = expand_east_indies_tt
		if = {
			limit= {
				any_state = {
					owner = ROOT
					region = sr:region_indonesia
				}
			}
			every_scope_state = {
				limit = {
					owner = ROOT
					region = sr:region_indonesia
				}
				set_state_owner = c:BEI
				set_state_type = unincorporated
			}
		}
		if = {
			limit= {
				any_subject_or_below = {
					capital.region = sr:region_indonesia
					NOT = { 
						THIS = c:BEI 
						is_subject_of = c:BEI 
					}
				}
			}
			every_subject_or_below = {
				if = {
					limit = { 
						is_subject_type = subject_type_protectorate
						capital.region = sr:region_indonesia
						NOT = { 
							THIS = c:BEI 
							is_subject_of = c:BEI 
						} 						
					}
					hidden_effect = { make_independent = yes }
					save_scope_as = new_bei_protectorate
					c:BEI = {
						create_diplomatic_pact = {
							country = scope:new_bei_protectorate
							type = protectorate
						}
					}
				}
				if = {
					limit = { 
						is_subject_type = subject_type_vassal
						capital.region = sr:region_indonesia
						NOT = { 
							THIS = c:BEI 
							is_subject_of = c:BEI 
						} 
					}
					hidden_effect = { make_independent = yes }
					save_scope_as = new_bei_vassal
					c:BEI = {
						create_diplomatic_pact = {
							country = scope:new_bei_vassal
							type = puppet
						}
					}
				}
				if = {
					limit = { 
						is_subject_type = subject_type_puppet
						capital.region = sr:region_indonesia
						NOT = { 
							THIS = c:BEI 
							is_subject_of = c:BEI 
						} 
					}
					hidden_effect = { make_independent = yes }
					save_scope_as = new_bei_puppet
					c:BEI = {
						create_diplomatic_pact = {
							country = scope:new_bei_puppet
							type = puppet
						}
					}
				}
			}
		}
	}
	ai_chance = {
		base = 100
	}
}

sca_expand_east_indies = {
	is_shown = {
		country_is_in_europe = yes
		exists = c:CHR
		c:CHR = {
			is_subject_of = ROOT
			is_subject_type = subject_type_dominion
		}
	}
	possible = {
		OR = { 
			any_state = {
				owner = ROOT
				region = sr:region_indonesia
			}
			any_subject_or_below = {
				capital.region = sr:region_indonesia
				NOT = { 
					THIS = c:CHR
					is_subject_of = c:CHR
				}
			}
		}
	}
	when_taken = {
		custom_tooltip = expand_east_indies_tt
		if = {
			limit= {
				any_state = {
					owner = ROOT
					region = sr:region_indonesia
				}
			}
			every_scope_state = {
				limit = {
					owner = ROOT
					region = sr:region_indonesia
				}
				set_state_owner = c:CHR
				set_state_type = unincorporated
			}
		}
		if = {
			limit= {
				any_subject_or_below = {
					capital.region = sr:region_indonesia
					NOT = { 
						THIS = c:CHR 
						is_subject_of = c:CHR 
					}
				}
			}
			every_subject_or_below = {
				if = {
					limit = { 
						is_subject_type = subject_type_protectorate
						capital.region = sr:region_indonesia
						NOT = { 
							THIS = c:CHR 
							is_subject_of = c:CHR 
						} 						
					}
					hidden_effect = { make_independent = yes }
					save_scope_as = new_chr_protectorate
					c:CHR = {
						create_diplomatic_pact = {
							country = scope:new_chr_protectorate
							type = protectorate
						}
					}
				}
				if = {
					limit = { 
						is_subject_type = subject_type_vassal
						capital.region = sr:region_indonesia
						NOT = { 
							THIS = c:CHR 
							is_subject_of = c:CHR 
						} 
					}
					hidden_effect = { make_independent = yes }
					save_scope_as = new_chr_vassal
					c:CHR = {
						create_diplomatic_pact = {
							country = scope:new_chr_vassal
							type = puppet
						}
					}
				}
				if = {
					limit = { 
						is_subject_type = subject_type_puppet
						capital.region = sr:region_indonesia
						NOT = { 
							THIS = c:CHR 
							is_subject_of = c:CHR 
						} 
					}
					hidden_effect = { make_independent = yes }
					save_scope_as = new_chr_puppet
					c:CHR = {
						create_diplomatic_pact = {
							country = scope:new_chr_puppet
							type = puppet
						}
					}
				}
			}
		}
	}
	ai_chance = {
		base = 100
	}
}